<?php
require_once 'Zend/Validate/Abstract.php';

class PasswordConfirm extends Zend_Validate_Abstract
{
    const MSG_NOMATCH = 'msgNoMatch';

	protected $_messageVariables = array(
			'password' => '_password',
			'confirm' => '_confirm'
			);

	protected $_password;
	protected $_confirm;
	
    protected $_messageTemplates = array(
				self::MSG_NOMATCH => "Passwords don't match"
				);

	public function __construct($password, $confirm)
	{
		$this->setPassword($password);
		$this->setConfirm($confirm);
	}
	
	public function getPassword()
	{
		return $this->_password;
	}
	
	public function getConfirm()
	{
		return $this->_confirm;
	}

	public function setPassword($password)
	{
		$this->_password = $password;
		return $this;
	}
	
	public function setConfirm($confirm)
	{
		$this->_confirm = $confirm;
		return $this;
	}

    public function isValid($value)
    {
        $this->_setValue($value);
		
        if ($this->_password != $this->_confirm) {
            $this->_error(self::MSG_NOMATCH);
            return false;
        }
		
        return true;
    }
}
?>
